package com.smedi.ismedi.authority.starter.util;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collection;

import static com.smedi.ismedi.authority.starter.common.Constant.DEFAULT_STRING;

/**
 * assert工具
 *
 * @author jiangqinxun
 * @date 2022/8/13 23:28
 */
@Component
@AllArgsConstructor
@Slf4j
public class VerifyHelper {

    public static Boolean isNull(Object object) {
        return null == object;
    }

    public static <T> Boolean isEmpty(Collection<T> collection) {
        return collection.isEmpty();
    }

    public static Boolean isBlank(String string) {
        return string.equals(DEFAULT_STRING);
    }

    public static Boolean isAvailable(Object object) {
        return !isNull(object);
    }

    public static <T> Boolean isAvailable(Collection<T> collection) {
        return !isNull(collection) && !isEmpty(collection);
    }

    public static Boolean isAvailable(String string) {
        return !isNull(string) && !isBlank(string);
    }

    public static Boolean isNotAvailable(Object object) {
        return !isAvailable(object);
    }

    public static <T> Boolean isNotAvailable(Collection<T> collection) {
        return !isAvailable(collection);
    }

    public static Boolean isNotAvailable(String string) {
        return !isAvailable(string);
    }
}


